public class LogIn {
    private String userName = "admin";
    private String password = "123456";

    public void loginInfo(String userName, String password)
            throws UserNameException, PasswordException {
        if (!this.userName.equals(userName)) {
            throw new UserNameException(userName + " 用户名错误！");
            //System.out.println("用户名错误！");
            //return;
        }
        if (!this.password.equals(password)) {
            throw new PasswordException(password + " 密码错误！");
            /*System.out.println("密码错误！");
            return;*/
        }
        System.out.println("登陆成功");
    }

    public static void main(String[] args) {
        LogIn logIn = new LogIn();
        try {
            logIn.loginInfo("admin", "123456111");
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}